/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSky.bridge.major;

import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import ru.jSky.finder.FinderByFormId;
import ru.jSky.interfaces.Armor;
import ru.jSky.interfaces.Enchantment;
import ru.jSky.interfaces.Keyword;
import ru.jSky.support.FormIdProducer;
import skyproc.ARMO;
import skyproc.FormID;

/**
 *
 * @author Rakev
 */
public class ArmorBridge extends DescriptionedMajorBridge<ARMO> implements Armor {

    public ArmorBridge(ARMO adapting) {
        super(adapting);
    }

    @Override
    public Enchantment getEnchantment() {
        FormID enchFormId = getAdapting().getEnchantment();
        return getFinderFactory().createEnchantmentFinder().find(enchFormId);
    }

    @Override
    public void setEnchantment(Enchantment enchantment) {
        FormID id = FormIdProducer.produce(enchantment);
        getAdapting().setEnchantment(id);
    }

    @Override
    public Armor getTemplate() {
        FormID templateFormId = getAdapting().getTemplate();
        return getFinderFactory().createArmorFinder().find(templateFormId);
    }

    @Override
    public void setTemplate(Armor template) {
        FormID id = FormIdProducer.produce(template);
        getAdapting().setTemplate(id);
    }

    @Override
    public Set<Keyword> getKeywords() {
        Collection<FormID> keyWordFormIds = getAdapting().getKeywordSet().getKeywordRefs();
        Collection<Keyword> keyWords = getFinderFactory().createKeywordFinder().find(keyWordFormIds);

        return new HashSet<>(keyWords);
    }
}
